import { post } from '../http'
import { cherryPick2Dict } from '@/utils/formatResponseData'

export const supplierPageData = () =>
  post({
    url: '/supplier/pageData',
    format: (res) =>
      cherryPick2Dict(res.result, {
        supplierTypeList: 'supplierTypeList', // 供应商类型
        enableList: 'enableList', // 状态管理
        invoiceTypeList: 'invoiceTypeList', // 发票类型
        settleTypeList: 'settleTypeList', // 供应商结算类型
      }),
  })

export const peerPageData = () =>
  post({
    url: '/sameIndustryInfo/toList',
    format: (res) => {
      res.result.settlementPlanEnum.forEach((item) => {
        switch (item.value) {
          case '10':
            item.desc = '费用生成后立即发起结算提醒'
            break
          case '20':
            item.desc = '每月固定日期进行结算提醒'
            break
          case '30':
            item.desc = '每个季度固定日期进行结算提醒'
            break
          case '40':
            item.desc = '每半年固定日期进行结算提醒'
            break
        }
      })
      return cherryPick2Dict(res.result, {
        industryStatusEnum: 'industryStatusEnum', // 状态管理
        settlementPlanEnum: 'settlementPlanEnum', // 结算方式
        invoiceTypeEnum: 'invoiceTypeEnum', // 发票类型
      })
    },
  })
